package com.atguigu.springcloud.controller;


import com.atguigu.springcloud.entities.CommomResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderController {


    @Resource
    private RestTemplate restTemplate;

    //真的很好吗


    public  static final  String payment_url="http://localhost:8001";


    @PostMapping("/comsumer/payment/create")
    public CommomResult<Payment> create(Payment payment){

        System.out.println(payment);
        return restTemplate.postForObject(payment_url+"payment/create",payment,CommomResult.class);
    }

    @GetMapping("/comsumer/payment/get/{id}")
    public CommomResult<Payment> getpaymentbyid(@PathVariable("id") Long id){



        return restTemplate.getForObject(payment_url+"/payment/get/"+id,CommomResult.class);
    }



}
